package com.xiumu.common.minio;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * minio 配置类
 */
@Data
@ConfigurationProperties(prefix = "minio.serve")
public class MinioProperties {

    /**
     * minio 服务地址
     */
    private String host;

    /**
     * 访问域名
     */
    private String domain;

    /**
     * 账号
     */
    private String accessKey;

    /**
     * 密码
     */
    private String secretKey;

    /**
     * 默认存储空间
     */
    private String defaultBucketName;

    public MinioProperties() {
    }

    public MinioProperties(String host, String domain, String accessKey, String secretKey, String defaultBucketName) {
        this.host = host;
        this.domain = domain;
        this.accessKey = accessKey;
        this.secretKey = secretKey;
        this.defaultBucketName = defaultBucketName;
    }

    public String getDomain() {
        // 给访问域名加上 /
        if (domain.charAt(domain.length() - 1) != '/') {
            return domain + "/";
        }
        return domain;
    }

}
